<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript">
        function copyUrl2() {
            var Url2 = document.getElementById("biao1");
            Url2.select(); // 选择对象
            document.execCommand("Copy"); // 执行浏览器复制命令
            alert("已复制好，可贴粘。");
        }
    </script>

</head>
<body>
<textarea cols="20" rows="10" id="biao1" placeholder="用户定义的代码区域"></textarea>
<br>
<input type="button" onClick="copyUrl2()" value="点击复制代码"/>
<input type="button" onClick="copyUrl2()" value="点击粘贴代码"/>
</body>
</html>